using System.Collections.Generic;
using System.Text;

namespace ColladaDotNet
{
	public partial class triangles : ColladaXmlNode
	{
		public triangles()
		{
			input = new InputLocalOffset[] { };
		}
		public override IList<ColladaXmlNode> ChildNodes
		{
			get
			{
				var list = new List<ColladaXmlNode>();
				if (input != null)
					foreach (object e in input) if (e is ColladaXmlNode) list.Add((ColladaXmlNode)e);
				if (extra != null)
					foreach (object e in extra) if (e is ColladaXmlNode) list.Add((ColladaXmlNode)e);
				return list;
			}
		}

		public InputLocalOffset CreateVertexInput(vertices source, ulong offset)
		{
			var res = new InputLocalOffset();
			res.offset = offset;
			res.semantic = "VERTEX";
			res.source = "#" + source.id;
			input = COLLADA.AddToArray(input, res);
			return res;
		}
		public InputLocalOffset CreateNormalInput(source source, ulong offset)
		{
			var res = new InputLocalOffset();
			res.offset = offset;
			res.semantic = "NORMAL";
			res.source = "#" + source.id;
			input = COLLADA.AddToArray(input, res);
			return res;
		}
		public InputLocalOffset CreateTexCoordInput(source source, ulong offset, ulong set)
		{
			var res = new InputLocalOffset();
			res.offset = offset;
			res.semantic = "TEXCOORD";
			res.set = set;
			res.source = "#" + source.id;
			input = COLLADA.AddToArray(input, res);
			return res;
		}
		public InputLocalOffset CreateColorInput(source source, ulong offset, ulong set)
		{
			var res = new InputLocalOffset();
			res.offset = offset;
			res.semantic = "COLOR";
			res.set = set;
			res.source = "#" + source.id;
			input = COLLADA.AddToArray(input, res);
			return res;
		}
		public void CreateIndexArray(int[] ints)
		{
			StringBuilder sb = new StringBuilder();
			string sep = "";
			foreach (var i in ints)
			{
				sb.Append(sep);
				sb.Append(i);
				sep = " ";
			}
			this.p = sb.ToString();
		}
	}
}
